Imports Microsoft.Win32
Imports Timer.clsCnsts
Imports Timer.clsConfigFile

Public Class clsChkRegKey

  Public Shared Function mPrSetKey(ByVal aObjKeyValue) As Boolean

    Dim lObjKey As RegistryKey

    Try
      If aObjKeyValue = True Then
        lObjKey = Registry.CurrentUser.OpenSubKey(CONST_RUN_AT_STARTUP_KEY, True)
        lObjKey.SetValue(CONST_RUN_AT_STARTUP_SUB_KEY, Application.ExecutablePath)
        lObjKey.Close()
        Return True
      Else
        lObjKey = Registry.CurrentUser.OpenSubKey(CONST_RUN_AT_STARTUP_KEY, True)
        lObjKey.DeleteValue(CONST_RUN_AT_STARTUP_SUB_KEY)
        lObjKey.Close()
        Return False
      End If
    Catch ex As Exception
      Return False
    End Try

  End Function


  Public Shared Function mPraChkKey() As Boolean

    Dim lObjKey As RegistryKey

    lObjKey = Registry.CurrentUser.OpenSubKey(CONST_RUN_AT_STARTUP_KEY, False)

    If lObjKey.GetValue(CONST_RUN_AT_STARTUP_SUB_KEY) = Application.ExecutablePath Then
      mFnWriteValue(CONST_CONFIG_INFO, _
                                  CONST_CONFIG_SYSTEMLOAD, _
                                  CONST_TRUE_VALUE, _
                                  Application.StartupPath + CONST_CONFIG_FILE)
      lObjKey.Close()
      Return True
    Else
      mFnWriteValue(CONST_CONFIG_INFO, _
                                  CONST_CONFIG_SYSTEMLOAD, _
                                  CONST_FALSE_VALUE, _
                                  Application.StartupPath + CONST_CONFIG_FILE)
      lObjKey.Close()
      Return False
    End If

  End Function

End Class
